<?php
// 登录
$loginName = $_REQUEST["loginName"];
$pwd = $_REQUEST["pwd"];

// TODO: 数据格式的验证

$conn = mysqli_connect("localhost:3306","root","","php");

$sql = "select id, login_name, nickname, create_date from t_user "
. " where login_name = '$loginName' and pwd = password('$pwd') ";
$result = mysqli_query($conn, $sql);
if($result){
    if(mysqli_num_rows($result)){
        // 登录成功
        // 保存当前登录的用户信息 到 session
        $_SESSION["loginUser"] = mysqli_fetch_assoc($result);
        //跳转首页
        header("location:/week_homework/doCenter.php");
    } else {
        // 登录失败
        echo "<h2 style='color:red;' >登录名或密码错误!</h2>";
    }
} else {
    echo "error: " . mysqli_error($conn);
}
mysqli_close($conn);

?>